
<template>
  <div class="section user-section">
    <div class="head">
      <van-nav-bar class="nav-bar">
        <template #left>
          <van-icon name="arrow-left" @click="router.go(-1)" />
        </template>
        <template #title>
          <div class="title">阅读文章</div>
        </template>
      </van-nav-bar>
    </div>
    <van-tabs v-model:active="active">
      <van-tab title="红色通信故事">
        <div
          class="reportCard"
          v-for="article in formState.articleList1"
          :key="article.id"
          @click="seeArticle(article.txtsrc)"
        >
          <van-card :thumb="article.imgsrc">
            <template #title>
              <div class="title">
                {{ article.title }}
              </div>
            </template>
            <template #desc>
              <div class="desc">{{ article.preview }}</div>
            </template>
          </van-card>
        </div>
      </van-tab>
      <van-tab title="守初心">
        <div
          class="reportCard"
          v-for="article in formState.articleList2"
          :key="article.id"
          @click="seeArticle(article.txtsrc)"
        >
          <van-card :thumb="article.imgsrc">
            <template #title>
              <div class="title">
                {{ article.title }}
              </div>
            </template>
            <template #desc>
              <div class="desc">{{ article.preview }}</div>
            </template>
          </van-card>
        </div>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script setup>
import { ref, reactive, computed, onMounted, watch } from "vue";
import { useRouter, useRoute } from "vue-router";
import { Dialog, Toast } from "vant";
import toasts from "/@/views/components/toasts";
import YuCard from "/@/components/YuCard";
import { useStore } from "vuex";
import { getArticle } from "/@/api/branch";
const loading = ref(false);

const router = useRouter();
const value = ref("");
const store = useStore();
const user = store.state.storage.user.userInfo;
const token = store.state.storage.user.token;
const active = ref(0);

const seeArticle = (src) => {
  window.location.href = src;
  window.open();
};
const formState = reactive({
  articleList1: [],
  articleList2: [],
});

onMounted(() => {
  getArticle(
    {
      articleType: "红色通信故事",
    },
    (res) => {
      if (res.code === 0) {
        formState.articleList1 = res.articleList;
      }
    }
  );
  getArticle(
    {
      articleType: "守初心",
    },
    (res) => {
      if (res.code === 0) {
        formState.articleList2 = res.articleList;
      }
    }
  );
});

// 获取报告
</script>


<style lang="scss" scoped>
.user-section {
  background: var(--yu-gray-color--light);
  min-height: 100vh;
  .reportCard {
    margin: 3px;
    border-radius: 3px;
    padding: 5px;

    .thumb {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      margin-top: 30px;
      font-size: medium;
    }
    .title {
      display: flex;
      align-items: center;
      justify-content: left;
      margin: 7px;
      font-size: large;
      font-weight: bold;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
      width: 5.5rem;
    }
    .desc {
      display: flex;
      align-items: center;
      margin: 7px;
      justify-content: center;
      font-size: small;
      color: var(--yu-color-disabled);
    }
  }

  .head {
    height: 50px;
    position: relative;
    .nav-bar {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      background: var(--yu-linear-bg-color);
      border: none;
      .van-icon {
        color: var(--yu-white-color);
      }
      .title {
        color: var(--yu-white-color);
      }
      &:after {
        border: none;
      }
    }
    .head-bg {
      height: 150px;
      background: var(--yu-linear-bg-color);
      position: relative;
      overflow: hidden;
      width: 100%;
      img {
        display: inline-block;
        position: absolute;
        width: 80px;
        height: auto;
        opacity: 0.2;
        &.img1 {
          top: 0;
          right: 0;
        }
        &.img2 {
          bottom: 0;
          left: 0;
        }
      }
    }
  }

  .user-info {
    position: absolute;
    top: 66px;
    left: 13px;
    width: calc(100% - 26px);
    z-index: 9;

    .card-body-wrapper {
      .avatar {
        width: 60px;
        height: 60px;
        overflow: hidden;
        border-radius: 50%;
        margin-right: 16px;
        box-shadow: var(--yu-border-shadow--light);
        img {
          width: 100%;
          height: 100%;
        }
      }
      .info {
        color: rgba(36, 45, 61, 1);
        font-size: 12px;
        line-height: 18px;
        padding-top: 10px;
        text-align: left;
        width: calc(100% - 60px - 16px);
        .user-name {
          margin-bottom: 4px;
          font-weight: 600;
        }
      }
    }
  }

  .body {
    padding: 0 13px;
    margin-top: 10px;
  }
  .user-info-card {
    display: block;
    width: 100%;
    padding: 0;
    margin-bottom: 8px;
  }
  .user-info-list {
    font-size: 15px;
  }
}
</style>